/**
 */
package com.powersi.biz.util.report.common;

import java.io.FileInputStream;
import java.util.Properties;
import org.apache.log4j.Logger;

/**
 * 资源文件配置
 */
public class ResConfig {
	private static Logger log = Logger.getLogger("ResConfig");
	
	private static String CONFIG_FILE = Thread.currentThread()
			.getContextClassLoader().getResource("messages.properties")
			.getPath().replace("%20", " ");
	private static Properties p;
	
	static {
		loadConfig();
	}
	
	//重新载入配置
	public static void reloadConfig(){
		loadConfig();
	}
	
	private static void loadConfig(){
		try {
			FileInputStream fs = new FileInputStream(CONFIG_FILE);
			p = new Properties();
			p.load(fs);
			fs.close();
		} catch (Exception ex) {
			log.warn("messages.properties reading has a Exception :"+ ex);
		}
	}

	public static String getProperty(String key){
		String value = p.getProperty(key);
		return value;
	}
	
	public static void main(String[] args) {
		String path = Thread.currentThread()
		.getContextClassLoader().getResource("messages.properties")
		.getPath();
		System.out.println(path);
	}
	
}
